Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: intersection inference across scopes #848

Merged
merged 2 commits into from
Sep 1, 2023
Merged

Conversation

ssalbdivad
Copy link
Member

Fixes a bug causing intersections including cross scope references to be inferred as unknown

Unfortunately, some cross-scope operations will still result in an error at runtime. You will know at build time if this occurs by a message in an intersection like "Unable to resolve alias 'myExternalAlias'". The workaround is to use the in-scope type parser as follows until next release for these scenarios:

Unions:

const $ = scope({
    a: "'abc'",
    b: { "c?": "a" }
})
const types = $.compile()
// This fails if you don't use scoped type for now, fixing in next release
const t = $.type([types.b, "|", { extraProp: "string" }])

Intersections:

const $ = scope({
    a: "'abc'",
    b: { "c?": "a" }
})
const types = $.compile()
// This fails if you don't use scoped type for now, fixing in next release
const t = $.type([types.b, "&", { extraProp: "string" }])

@ssalbdivad ssalbdivad merged commit a072173 into main Sep 1, 2023
5 checks passed
@ssalbdivad ssalbdivad deleted the scope-intersection-fix branch September 1, 2023 00:29
ahrjarrett pushed a commit to ahrjarrett/arktype-fork that referenced this pull request May 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done (merged or closed)
Development

Successfully merging this pull request may close these issues.

1 participant